package wanyi.algorithm.basic.analysisAnddesign.chapter1;

//import java.util.Comparator;

public class Practice0103 {
	
	public boolean IsOrdered (int[] a)
	{
		int n = a.length;
		int j = 0;
		while ((j < n - 1) && ((a[j] - a[j+1]) == 0))
		{
			++j;
			System.out.println(a[j] + "  " + a[j+1]);
		}
		if ((n <= 1) || (j == n-1))
		{
			System.out.println("All Elements are equal !");
			return true;
		}
		else
		{
			j = a[j] - a[j+1];
		}
		for (int i = 0; i < n-1; ++i)
		{
			if ((a[i] - a[i+1]) * j < 0)
			{
				return false;
			}
		}
		return true;
	}
}
